home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Frameworks / MacZoop 1.6.5 / More Classes / Window Classes / ZScroller.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-14  |  3.4 KB  |  139 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************************
  2. *
  3. *
  4. *            ObjectMacZapp        -- a standard Mac OOP application template
  5. *
  6. *
  7. *
  8. *            ZScroller.h            -- a window with scrollbars
  9. *
  10. *
  11. *
  12. *
  13. *
  14. *            © 1996, Graham Cox
  15. *
  16. *
  17. *
  18. *
  19. *************************************************************************************************/
  20.  
  21.  
  22. #pragma once
  23.  
  24. #ifndef __ZSCROLLER__
  25. #define    __ZSCROLLER__
  26.  
  27. #ifndef __ZDRAGDROPWINDOW__
  28. #include    "ZDragDropWindow.h"
  29. #endif
  30.  
  31. /*
  32.  ZScroller is a window that has scrollbars in the usual way. The scrollBounds sets the size
  33.  of the area that the window can show- if this is ever less than the window content the
  34.  scrollbars will be disabled. The scale values set how many pixels to move in each direction
  35.  for each increment of the scrollbar. Override this class to implement scrolling windows with
  36.  REAL content.
  37. */
  38.  
  39.  
  40. class    ZScroller : public ZDragDropWindow
  41. {
  42. protected:
  43.     ControlHandle        theHBar;
  44.     ControlHandle        theVBar;
  45.     Rect                bounds;
  46.     short                hScale;
  47.     short                vScale;
  48.     Boolean                hasHBar;
  49.     Boolean                hasVBar;
  50.     short                cInitValue;
  51.  
  52. public:
  53.     
  54.     ZScroller(    ZCommander* aBoss,
  55.                 const short windID,
  56.                 const Boolean hasHScroll = TRUE,
  57.                 const Boolean hasVScroll = TRUE );
  58.     
  59.     virtual void    InitZWindow();
  60.     virtual void    Activate();
  61.     virtual void    Deactivate();
  62.     virtual void    Draw();
  63.     virtual void    DrawGrow();
  64.     virtual void    Click( const Point mouse, const short modifiers );
  65.     virtual void    SetSize( const short width, const short height, const Boolean reDraw = TRUE);
  66.     virtual void    Zoom( const short partCode );
  67.     virtual void    SetBounds( const Rect& aBounds );
  68.     virtual void    GetBounds( Rect* aBounds );
  69.     virtual void    SetScrollAmount( const short hAmount, const short vAmount );
  70.     virtual void    GetPosition( short* hPosition, short* vPosition );
  71.     virtual void    ScrollTo( const short hPosition, const short vPosition );
  72.     virtual void    GetContentRect( Rect* aRect );
  73.     virtual void    ClickContent( const Point mouse, const short modifiers );
  74.     virtual void    Scroll( const short dH, const short dV );
  75.  
  76. protected:
  77.  
  78.     virtual void    CalculateControlParams();
  79.     virtual void    MakeScrollbars();
  80.     virtual void    MoveScrollbars();
  81.     virtual void    PostScroll( ControlHandle aCtl = NULL );
  82.     virtual void    SetOriginToScroll();
  83.  
  84. public:
  85.  
  86.     virtual void    ScrollHandler( const ControlHandle aCtl, const short partCode );
  87. };
  88.  
  89.  
  90.  
  91. // compiler flags:
  92.  
  93. // ZScroller by default sets up a thumb action procedure to implement "live scrolling". If you'd
  94. // prefer to use the more traditional non-live scrolling, undefine the following conditional.
  95.  
  96. #define    _LIVE_SCROLLING        1
  97.  
  98. // for live scrolling we require a UPP definition for the thumb proc- Apple's interfaces
  99. // omit this, so we do that here
  100.  
  101. #ifdef _LIVE_SCROLLING
  102.  
  103. #define            kWidthOfScrollArrow        24
  104.  
  105. // UPP:
  106.  
  107. typedef pascal void    (*ThumbActionProcPtr)();
  108.  
  109. #if GENERATINGCFM
  110. typedef UniversalProcPtr ThumbActionUPP;
  111. #else
  112. typedef ThumbActionProcPtr ThumbActionUPP;
  113. #endif
  114.  
  115. enum
  116. {
  117.     uppThumbActionProcInfo = kPascalStackBased
  118. };
  119.  
  120. #if GENERATINGCFM
  121. #define NewThumbActionProc(userRoutine)        \
  122.         (ThumbActionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppThumbActionProcInfo, GetCurrentArchitecture())
  123. #else
  124. #define NewThumbActionProc(userRoutine)        \
  125.         ((ThumbActionUPP) (userRoutine))
  126. #endif
  127.  
  128. #if GENERATINGCFM
  129. #define CallThumbActionProc(userRoutine)        \
  130.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppThumbActionProcInfo )
  131. #else
  132. #define CallThumbActionProc(userRoutine )        \
  133.         (*(userRoutine))()
  134. #endif
  135.  
  136.  
  137. #endif
  138.  
  139. #endif